<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class InitUpdate36 extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->integer('root_inviter_id')->nullable()->index()->comment('最顶层邀请用户的id'); 
            $table->integer('indirect_inviter_id')->nullable()->index()->comment('上上级推广者的id'); 
            $table->json('invite_base_reward')->nullable()->comment('上级邀请时获得的基础奖励'); 

            $table->integer('paid_money_total')->default(0)->comment('消费总人民币金额'); 
            $table->integer('paid_score_total')->default(0)->comment('消费总积分金额'); 

            $table->integer('first_money_brokerage')->default(0)->comment('上级人民币佣金'); 
            $table->integer('first_score_brokerage')->default(0)->comment('上级积分佣金'); 

            $table->integer('second_money_brokerage')->default(0)->comment('上上级人民币佣金'); 
            $table->integer('second_score_brokerage')->default(0)->comment('上上级积分佣金'); 
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function (Blueprint $table) {

            $table->dropColumn(['root_inviter_id', 'indirect_inviter_id', 'invite_base_reward', 'first_money_brokerage', 'first_score_brokerage', 'second_money_brokerage', 'second_score_brokerage', 'paid_money_total', 'paid_score_total']);
        });
    }
}
